

# 封装MySQL数据库redis数据库：
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker

import pymysql
pymysql.install_as_MySQLdb()

engine = create_engine("mysql://root:root@localhost:3306/zhoumo")

# 已经具备了上下文的功能：
Session =sessionmaker(engine)


import redis
from config import *

# 封装redis数据库：
# class R():
#
#     def __enter__(self):
#         self.r = redis.Redis(host=redis_host,port=redis_port,db=5,decode_responses=True)
#         return self.r
#
#     def __exit__(self,*args):
#         self.r.close()
#
#
# if __name__ == '__main__':
#
#     with R()as r:
#         r.set('123','123')
#         info = r.get('123')
#     print(info)
























